/****************************************************************************************
*                                                                                      *
*                          Projeto BioInfo - Lincs and CIn / UFPE                      *
*                                    07/10/2014                                        *
*																					   *
****************************************************************************************
* Descricao: Arquivo que contem a classe Threads.                    *
****************************************************************************************
* Responsaveis: Jefferson Ramos (jrla)													   *
*                                                                                      */
/*                                                                                     *
****************************************************************************************/

#ifndef THREADS_HPP_
#define THREADS_HPP_

#include <cstdio>
#include <cstdlib>
#include <string>
#include <time.h>
#include <math.h>
#include <malloc.h>
#include <iostream>
#include <thread>
#include <vector>
#include "util.hpp"

class Threads{

	int NUM_THREADS = 1;
	int TAMSEQ = 252;
	int query_compare = 1; //query escolhida
	int run_times = 5;
	int alignment_by_individuals = 1;
	int num_individuals = 8;
	int alignment_by_threads = 1;

public:

	double time_average = 0.0;
	double sum_time = 0.0;

	vector<thread> vector_thread;

	int *vector_taxa;
	int *score_vector;

	FILE *Results;
	FILE *TaxaOut;
	FILE *BD_nucleotideos;

	TypeQuery *query;
	TypeMat_direction *mat_direction;
	TypeIndividuals *individuals;
	TypeIndividuals *store_individuals;

	Threads(
				int NUM_THREADS,
				int TAMSEQ,
				int alignment_by_individuals,
				int num_individuals,
				int query_compare,
				int run_time
				);

//	**********************************************
//		Destrutor da classe Canonic
//	**********************************************
	virtual ~Threads();

	void read_input_individuals();

	void read_input_query();

	int maximum( 
					int diag1, int diag2, int diag3, int diag4,
					int *cust_diag, int *score_up, int left,
					byte_Union *direction
					);

	int vectors_malloc();

	void run();

	void print_results();

	void threads_needlemanwunsch( void *threadid );


	void set_alignment_by_threads( int alignment_by_threads ){
		this->alignment_by_threads = alignment_by_threads;
	}

	void set_num_individuals( int alocation_max_ind ){
		this->num_individuals = alocation_max_ind;
	}

	int get_num_individuals(){
		return this->num_individuals;
	}
};

#endif THREADS_HPP_